package com.rw.mqdemo.mq;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

@Component
public class MQConsumer {
    @RabbitListener(queues = "${app.rabbitmq.queueName1}")
    public void ReceivingQueue1(@Payload String msg, @Header(AmqpHeaders.RECEIVED_ROUTING_KEY)
            String key) {
        System.out.println("queueName1 - key：" + key + "，context：" + msg);
    }
    @RabbitListener(queues = "${app.rabbitmq.queueName2}")
    public void ReceivingQueue2(String msg) {
        System.out.println("queueName2 - " + msg);
    }
}
